package com.gaohe.help.controller;

import java.util.List;
import java.io.IOException;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gaohe.common.log.annotation.Log;
import com.gaohe.common.log.enums.BusinessType;
import com.gaohe.common.security.annotation.RequiresPermissions;
import com.gaohe.help.domain.FmHelpReceive;
import com.gaohe.help.service.IFmHelpReceiveService;
import com.gaohe.common.core.web.controller.BaseController;
import com.gaohe.common.core.web.domain.AjaxResult;
import com.gaohe.common.core.utils.poi.ExcelUtil;
import com.gaohe.common.core.web.page.TableDataInfo;

/**
 * 订单接单Controller
 * 
 * @author ruoyi
 * @date 2025-06-03
 */
@RestController
@RequestMapping("/receive")
public class FmHelpReceiveController extends BaseController
{
    @Autowired
    private IFmHelpReceiveService fmHelpReceiveService;

    /**
     * 查询订单接单列表
     */
    @RequiresPermissions("help:receive:list")
    @GetMapping("/list")
    public TableDataInfo list(FmHelpReceive fmHelpReceive)
    {
        startPage();
        List<FmHelpReceive> list = fmHelpReceiveService.selectFmHelpReceiveList(fmHelpReceive);
        return getDataTable(list);
    }

    /**
     * 导出订单接单列表
     */
    @RequiresPermissions("help:receive:export")
    @Log(title = "订单接单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FmHelpReceive fmHelpReceive)
    {
        List<FmHelpReceive> list = fmHelpReceiveService.selectFmHelpReceiveList(fmHelpReceive);
        ExcelUtil<FmHelpReceive> util = new ExcelUtil<FmHelpReceive>(FmHelpReceive.class);
        util.exportExcel(response, list, "订单接单数据");
    }

    /**
     * 获取订单接单详细信息
     */
    @RequiresPermissions("help:receive:query")
    @GetMapping(value = "/{helpReceiveId}")
    public AjaxResult getInfo(@PathVariable("helpReceiveId") Long helpReceiveId)
    {
        return success(fmHelpReceiveService.selectFmHelpReceiveByHelpReceiveId(helpReceiveId));
    }

    /**
     * 新增订单接单
     */
    @RequiresPermissions("help:receive:add")
    @Log(title = "订单接单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FmHelpReceive fmHelpReceive)
    {
        return toAjax(fmHelpReceiveService.insertFmHelpReceive(fmHelpReceive));
    }

    /**
     * 修改订单接单
     */
    @RequiresPermissions("help:receive:edit")
    @Log(title = "订单接单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FmHelpReceive fmHelpReceive)
    {
        return toAjax(fmHelpReceiveService.updateFmHelpReceive(fmHelpReceive));
    }

    /**
     * 删除订单接单
     */
    @RequiresPermissions("help:receive:remove")
    @Log(title = "订单接单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{helpReceiveIds}")
    public AjaxResult remove(@PathVariable Long[] helpReceiveIds)
    {
        return toAjax(fmHelpReceiveService.deleteFmHelpReceiveByHelpReceiveIds(helpReceiveIds));
    }
}
